/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.mappingtable.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import uimigration.WidgetsModel.Property;
import uimigration.mappingtable.MappingPositionningProperties;
import uimigration.mappingtable.MappingtablePackage;
import uimigration.mappingtable.PositionningType;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mapping Positionning Properties</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.mappingtable.impl.MappingPositionningPropertiesImpl#getPositionType <em>Position Type</em>}</li>
 *   <li>{@link uimigration.mappingtable.impl.MappingPositionningPropertiesImpl#getProperty <em>Property</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MappingPositionningPropertiesImpl extends EObjectImpl implements
		MappingPositionningProperties {
	/**
	 * The default value of the '{@link #getPositionType() <em>Position Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPositionType()
	 * @generated
	 * @ordered
	 */
	protected static final PositionningType POSITION_TYPE_EDEFAULT = PositionningType.ABSOLUTE_LITERAL;
	/**
	 * The cached value of the '{@link #getPositionType() <em>Position Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPositionType()
	 * @generated
	 * @ordered
	 */
	protected PositionningType positionType = POSITION_TYPE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getProperty() <em>Property</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProperty()
	 * @generated
	 * @ordered
	 */
	protected Property property;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MappingPositionningPropertiesImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return MappingtablePackage.Literals.MAPPING_POSITIONNING_PROPERTIES;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Property getProperty() {
		return property;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetProperty(Property newProperty,
			NotificationChain msgs) {
		Property oldProperty = property;
		property = newProperty;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(
					this,
					Notification.SET,
					MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__PROPERTY,
					oldProperty, newProperty);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setProperty(Property newProperty) {
		if (newProperty != property) {
			NotificationChain msgs = null;
			if (property != null)
				msgs = ((InternalEObject) property)
						.eInverseRemove(
								this,
								EOPPOSITE_FEATURE_BASE
										- MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__PROPERTY,
								null, msgs);
			if (newProperty != null)
				msgs = ((InternalEObject) newProperty)
						.eInverseAdd(
								this,
								EOPPOSITE_FEATURE_BASE
										- MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__PROPERTY,
								null, msgs);
			msgs = basicSetProperty(newProperty, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(
					this,
					Notification.SET,
					MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__PROPERTY,
					newProperty, newProperty));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PositionningType getPositionType() {
		return positionType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPositionType(PositionningType newPositionType) {
		PositionningType oldPositionType = positionType;
		positionType = newPositionType == null ? POSITION_TYPE_EDEFAULT
				: newPositionType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(
					this,
					Notification.SET,
					MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__POSITION_TYPE,
					oldPositionType, positionType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__PROPERTY:
			return basicSetProperty(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__POSITION_TYPE:
			return getPositionType();
		case MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__PROPERTY:
			return getProperty();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__POSITION_TYPE:
			setPositionType((PositionningType) newValue);
			return;
		case MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__PROPERTY:
			setProperty((Property) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__POSITION_TYPE:
			setPositionType(POSITION_TYPE_EDEFAULT);
			return;
		case MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__PROPERTY:
			setProperty((Property) null);
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__POSITION_TYPE:
			return positionType != POSITION_TYPE_EDEFAULT;
		case MappingtablePackage.MAPPING_POSITIONNING_PROPERTIES__PROPERTY:
			return property != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (positionType: ");
		result.append(positionType);
		result.append(')');
		return result.toString();
	}

} //MappingPositionningPropertiesImpl
